package com.carbohydrate42.kotlin_compose_demo.compose

import android.util.Log
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Button
import androidx.compose.material3.Text
import androidx.compose.runtime.*
import androidx.compose.ui.tooling.preview.Preview
import com.carbohydrate42.kotlin_compose_demo.constant.Common
import com.carbohydrate42.kotlin_compose_demo.viewModel.TryCoroutineViewModel

@Preview(showSystemUi = true, showBackground = true)
@Composable
fun TryCoroutine(
    tryCoroutineViewModel: TryCoroutineViewModel = TryCoroutineViewModel()
) {
    var thisCount by remember { mutableStateOf(0) }

    Column() {


        Button(onClick = {
            tryCoroutineViewModel.runTestApi()
        }) {
            Text(text = tryCoroutineViewModel.jsonString)
        }

        Button(onClick = {
            tryCoroutineViewModel.countInc()
        }
        ) {
            Text(text = tryCoroutineViewModel.count.toString())
        }

        Button(onClick = {
            Log.d(Common.ANDROID_LOG_TAG.label, "click2")
            tryCoroutineViewModel.count2Inc()
        }
        ) {
            Text(text = tryCoroutineViewModel.count2.toString())
        }


        Button(onClick = {
            tryCoroutineViewModel.changeJsonStr()
        }) {
            Text(text = tryCoroutineViewModel.jsonString)
        }

        Button(onClick = { thisCount++ }) {
            Text(text = "this count $thisCount")
        }

    }
}